<div class="page-header">
    <h1>
        守护购买单据信息列表
        <small>
            <i class="ace-icon fa fa-angle-double-right"></i>
        </small>
    </h1>
</div>
<div class="row">
    <div class="col-xs-12">
        <table id="dtpList" class="dataTable">
            <tfoot>
            <tr>
                <td colspan="5">本页合计：</td>
                <td>
                    <span name="Order_Amt" class="tooltip-"/>
                </td>
                <td>
                    <span name="Order_Amt_Anchor" class="tooltip-"/>
                </td>
                <td>
                    <span name="Order_Amt_Family" class="tooltip-"/>
                </td>
                <td>
                    <span name="Order_Amt_Platform" class="tooltip-"/>
                </td>
                <td></td>
            </tr>
            </tfoot>
        </table>
        <div id="dtpList_filter" class="dataTables_filter">
            <div>
                <select id="dtpList_F_SType" class="selectpicker" data-style="btn btn-info btn-sm" data-width="90px">
                    <option value="">模糊查询</option>
                    <option data-divider="true"></option>
                    <option value="Order_No">单据号</option>
                    <option value="User_ID">守护人ID</option>
                    <option value="User_NickName">守护人昵称</option>
                    <option value="User_ID_Guardian">被守护人ID</option>
                    <option value="User_NickName_Guardian">被守护人昵称</option>
                    <option value="Family_Name">公会名</option>
                </select>
                <input id="dtpList_F_SValue" class="fvalue" type="text"/>
                <select id="dtpList_F_Family" style="width: 186px;" data-databind="Family"></select>
                <select id="dtpList_F_Guardian" style="width: 86px;" data-databind="CommodityGuardian" placeholder="守护..."></select>
                <input id="dtpList_F_UserID" type="text" style="width: 70px;" placeholder="守护人ID">
                <input id="dtpList_F_UserIDGuardian" type="text" style="width: 70px;" placeholder="被守护人ID">
                <input id="dtpList_F_StartDate" type="text" style="width: 76px;" placeholder="开始时间">
                <label>-</label>
                <input id="dtpList_F_EndDate" type="text" style="width: 76px;" placeholder="结束时间">
                <select id="dtpList_F_SelectDate"></select>
                <button id="dtpList_F_Btn"></button>
            </div>
        </div>
    </div>
</div>
<script src="<%- Virtual_Path.Static %>jquery.plugin/dataTables/jquery.dataTables.min.js"></script>
<script src="<%- Virtual_Path.Static %>jquery.plugin/dataTables/jquery.dataTables.bootstrap.min.js"></script>
<script>
    $(function () {
        //region 时间输入框插件
        $('#dtpList_F_StartDate, #dtpList_F_EndDate').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: 2,
            autoclose: true
        });
        //endregion
        //region 绑定日期选择框
        $.KOC.Date.Select.Bind({
            eSelect: $('#dtpList_F_SelectDate'),
            eBegin: $('#dtpList_F_StartDate'),
            eEnd: $('#dtpList_F_EndDate')
        });
        //endregion
        //region dtpList
        $("#dtpList").dataTable({
            'aoColumns': [
                {
                    'sWidth': '120px', 'data': 'Order_No', 'sName': 'Order_No', 'sTitle': "单据号", 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).html($('<a/>').attr('data-openwindow', cellData).text(cellData));
                    }
                },
                {
                    'sWidth': '16%', 'data': 'Family_Name', 'sName': 'Family_ID', 'sTitle': '公会名', 'sClass': 'center t-left'
                },
                {
                    'sWidth': '10%', 'data': 'User_ID', 'sName': 'User_ID', 'sTitle': '守护人', 'sClass': 'center t-left',
                    'createdCell': function (td, cellData, rowData) {
                        $(td).html($('<a/>').attr('data-openwindow', ':UserInfo:' + cellData).text(rowData.User_NickName));
                    }
                },
                {
                    'sWidth': '10%', 'data': 'User_ID_Guardian', 'sTitle': '被守护人', 'sClass': 'center t-left',
                    'createdCell': function (td, cellData, rowData) {
                        $(td).html($('<a/>').attr('data-openwindow', ':UserInfo:' + cellData).text(rowData.User_NickName_Guardian));
                    }
                },
                {
                    'data': 'Guardian_Name', 'sTitle': '守护名称', 'sClass': 'center t-left', bSortable: false
                },
                {
                    'sWidth': '93px', 'data': 'Order_Amt', 'sName': 'Order_Amt', 'sTitle': '金额', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        if (cellData > 0) {
                            $(td).html('<span class="tooltip-" data-rel="tooltip" data-original-title="金币价值：' + $.KOC.String.ToCurrencyPositiveStr(cellData / 1000) + '">' + cellData + '</span>');
                        }
                    }
                },
                {
                    'sWidth': '93px', 'data': 'Order_Amt_Anchor', 'sName': 'Order_Amt_Anchor', 'sTitle': '艺人收入', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        if (cellData > 0) {
                            $(td).html('<span class="tooltip-" data-rel="tooltip" data-original-title="金币价值：' + $.KOC.String.ToCurrencyPositiveStr(cellData / 1000) + '">' + cellData + '</span>');
                        }
                    }
                },
                {
                    'sWidth': '93px', 'data': 'Order_Amt_Family', 'sName': 'Order_Amt_Family', 'sTitle': '公会收入', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        if (cellData > 0) {
                            $(td).html('<span class="tooltip-" data-rel="tooltip" data-original-title="金币价值：' + $.KOC.String.ToCurrencyPositiveStr(cellData / 1000) + '">' + cellData + '</span>');
                        }
                    }
                },
                {
                    'sWidth': '93px', 'data': 'Order_Amt_Platform', 'sName': 'Order_Amt_Platform', 'sTitle': '平台收入', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        if (cellData > 0) {
                            $(td).html('<span class="tooltip-" data-rel="tooltip" data-original-title="金币价值：' + $.KOC.String.ToCurrencyPositiveStr(cellData / 1000) + '">' + cellData + '</span>');
                        }
                    }
                },
                {
                    'sWidth': '13%', 'data': 'Create_Date', 'sName': 'Order_No', 'sTitle': '时间', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).text(moment(cellData).format('YY/MM/DD HH:mm'));
                    }
                }
            ],
            'aaSorting': [0, 'desc'],
            'sAjaxSource': '/ajax/user.page.orderguardian',
            'fnServerParams': function (aoData) {
                if (!this.arrPageFilter) {
                    this.arrPageFilter = {
                        F_Family: $(this.selector + '_F_Family').val(),
                        F_Guardian: $(this.selector + '_F_Guardian').val(),
                        F_UserID: $(this.selector + '_F_UserID').val(),
                        F_UserIDGuardian: $(this.selector + '_F_UserIDGuardian').val(),
                        F_StartDate: $(this.selector + '_F_StartDate').val(),
                        F_EndDate: $(this.selector + '_F_EndDate').val()
                    };
                } else {
                    $(this.selector + '_F_Family').val(this.arrPageFilter.F_Family);
                    $(this.selector + '_F_Guardian').val(this.arrPageFilter.F_Guardian);
                    $(this.selector + '_F_UserID').val(this.arrPageFilter.F_UserID);
                    $(this.selector + '_F_UserIDGuardian').val(this.arrPageFilter.F_UserIDGuardian);
                    $(this.selector + '_F_StartDate').val(this.arrPageFilter.F_StartDate);
                    $(this.selector + '_F_EndDate').val(this.arrPageFilter.F_EndDate);
                }
                this.ofnServerParams(aoData);
            },
            'fnFooterCallback': function (nFoot, aData) {
                var _FooterData = {
                    Order_Amt: 0,
                    Order_Amt_Anchor: 0,
                    Order_Amt_Family: 0,
                    Order_Amt_Platform: 0
                };
                _.forEach(aData, function (ThisValue) {
                    _FooterData.Order_Amt += ThisValue.Order_Amt;
                    _FooterData.Order_Amt_Anchor += ThisValue.Order_Amt_Anchor;
                    _FooterData.Order_Amt_Family += ThisValue.Order_Amt_Family;
                    _FooterData.Order_Amt_Platform += ThisValue.Order_Amt_Platform;
                });
                $(nFoot).find('[name="Order_Amt"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金币价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Order_Amt / 1000)
                }).text(_FooterData.Order_Amt);
                $(nFoot).find('[name="Order_Amt_Anchor"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金币价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Order_Amt_Anchor / 1000)
                }).text(_FooterData.Order_Amt_Anchor);
                $(nFoot).find('[name="Order_Amt_Family"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金币价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Order_Amt_Family / 1000)
                }).text(_FooterData.Order_Amt_Family);
                $(nFoot).find('[name="Order_Amt_Platform"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金币价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Order_Amt_Platform / 1000)
                }).text(_FooterData.Order_Amt_Platform);
            },
            'fnDrawCallback': function () {
                $.Common.Bootstrap.Tooltip(this);
                this.ofnDrawCallback();
            },
            'selectOpt': {}
        });
        //endregion
    });
</script>